#define _CRT_SECURE_NO_WARNINGS 1
#include <bits/stdc++.h>
using namespace std;

vector<string> result;

bool isValid(string& s, int start, int end) {
	if (s[start] == '0' && start == end)
		return false;
	int num = 0;
	for (int i = start; i <= end; i++) {
		num += s[i] - '0';
		if (i < end)
			num *= 10;
	}
	if (num > 255)
		return false;
	return true;
}
void backtracking(string& s, int index, int num, string tmp) {
	if (num == 3) {
		if (isValid(s, index, s.size() - 1)) {
			tmp += s.substr(index);
			result.push_back(tmp);
		}
		return;
	}
	for (int i = index; i < s.size() && i - index + 1 <= 3; i++) {
		if (isValid(s, index, i)) {
			tmp += s.substr(index, i - index + 1);
			if (num < 3)
				tmp += '.';
			backtracking(s, i + 1, num + 1, tmp);
			tmp.erase(index + num);
		}
	}
}
vector<string> restoreIpAddresses(string s) {
	if (s.size() < 4)
		return result;
	backtracking(s, 0, 0, "");
	return result;
}




int main()
{
	string s = "25525511135";
	restoreIpAddresses(s);

}